package holdObject;

import java.util.ArrayList;
import java.util.List;

public class Gerbil {

	private int gerbilNumber;
	
	public Gerbil(int gerbilNumber){
		this.gerbilNumber = gerbilNumber;
	}

	public int getGerbilNumber() {
		return gerbilNumber;
	}

	public void setGerbilNumber(int gerbilNumber) {
		this.gerbilNumber = gerbilNumber;
	}
	
	public void hop(){
		System.out.println(gerbilNumber+"号沙鼠正在跳跃");
	}
	public static void main(String[] args){
		List<Gerbil> list = new ArrayList<>();
		for (int i = 0; i < 5; i++) {
			list.add(new Gerbil(i));
		}
		for (Gerbil gerbil:list) {
			gerbil.hop();
		}
	}
}
